package com.itheima.sc.web.cms;

import com.itheima.sc.pojo.cms.PrefrenceArea;
import com.itheima.sc.pojo.cms.Subject;
import com.itheima.sc.result.Result;
import com.itheima.sc.service.cms.SubjectService;
import com.itheima.sc.vo.PageResult;
import io.jsonwebtoken.impl.crypto.MacProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/subject")
public class SubjectController {

    @Autowired
    private SubjectService subjectService;

    //根据专题名称分页获取商品专题
    @GetMapping("/list")
    public Result pageList(@RequestParam Map<String, String> param) {
        PageResult pageResult = subjectService.pageList(param);
        return Result.success(pageResult);
    }

    @GetMapping("/listAll")
    public Result listAll() {
        List<Subject> subjects = subjectService.listAll();
        return Result.success(subjects);
    }
}
